#    Copyright 2011 Tri-County Electric Cooperative, St. Matthews, South Carolina
#    This file is part of COOPIP.
#    COOPIP is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#    COOPIP is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#    You should have received a copy of the GNU General Public License
#    along with COOPIP.  If not, see <http://www.gnu.org/licenses/>.

#************************BEGIN Add Include Files to Path************************
COOPIPPath='/opt/coopip/'
LogFileName='/opt/coopip/log'
import sys, os
NeededPaths=[COOPIPPath + 'djangoproject/include', COOPIPPath + '/djangoproject', COOPIPPath + 'djangoproject/models']
for path in NeededPaths:
    if(not path in sys.path):
        sys.path.append(path)
os.system('export DJANGO_SETTINGS_MODULE=djangoproject.settings')
#************************END   Add Include Files to Path************************

DEBUG=True
import sys
import os
COOPIPServerIPAddress='SCRUBBED'
COOPGISServerIPAddress='SCRUBBED'
AMRMeterSearchBatchFileName = '/opt/coopip/scripts/amr/COOPIP_DynamicBatchMeterFile.txt'
COOPIPersion=['COOPIP', '05/04/2011', '0', '0', '0', 'Development']  #Program Name, Date, Release, Major, Minor, Status
COOPIPSRID=2273
COOPIPGPSSRID=4326
COOPIPDistanceMultiplier=1 #Multiplier used for all distance calculations, intended to be Conversion Factor to Convert Feet to Whatever unit used by the SRID
COOPGISSRID=2273
COOPGISGPSSRID=4326
COOPGISDistanceMultiplier=1
BatchAMRFileName='/mnt/amr/users/tcec/batch/COOPIP_Batch.dat'  #/etc/fstab line for this share:  //192.168.100.98/AMR2_f /mnt/amr cifs username=anonymous,password=anonymous
AMRIPAddress='SCRUBBED'
AMRLogFileUserName='SCRUBBED'
AMRLogFilePassword='SCRUBBED'
AMRLogFileName='GenStatus.LOG'
AMRBatchUserName='SCRUBBED'
AMRBatchPassword='SCRUBBED'
FakeMeterSerialNumbers=[123,456,789,147]
NonMiraSubstations=['SILVER LAKE','ST MATTHEWS','WELLS']
SMORouterUserName='SCRUBBED'
SMORouterPassword='SCRUBBED'
SMORouterIPAddress='SCRUBBED'
RDORouterIPAddress='SCRUBBED'
SDORouterIPAddress='SCRUBBED'
TEMPLATE_DEBUG = DEBUG

AlarmUsername='SCRUBBED'
AlarmPassword='SCRUBBED'
AlarmArmPath='/opt/coopip/alarm/arm/'
AlarmDisarmPath='/opt/coopip/alarm/disarm/'
AlarmGetStatusPath='/opt/coopip/alarm/getstatus/'

CISReportBarcodePDFLocation='/var/www/cisreportbarcodepdf/'
RevenueProtectionNightlyPDFReportLocation='/opt/coopip/media/revenueprotectionreport/'


ADMINS = ( # ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS

DATABASES={}
DATABASES['default']={
'ENGINE': 'django.contrib.gis.db.backends.postgis',           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'coopip',                # Or path to database file if using sqlite3.
'USER': 'SCRUBBED',       # Not used with sqlite3.
'PASSWORD': 'SCRUBBED',         # Not used with sqlite3.
'HOST': 'localhost',             # Set to empty string for localhost. Not used with sqlite3.
'PORT': '',             # Set to empty string for default. Not used with sqlite3.
}



COOPIPIntranetApplicationName='Intranet'


#************************BEGIN Optional OMS Import************************
def ImportOMS():
    try:
        IncludePath="/opt/oms"
        if(not IncludePath in sys.path):
            sys.path.append(IncludePath)
        import COOPIPOMSSetup
        COOPIPOMSSetup.DefineDatabases(DATABASES)
    except:
        pass
#************************BEGIN Optional AMR Import************************
def ImportAMR():
    try:
        IncludePath="/opt/amr"
        if(not IncludePath in sys.path):
            sys.path.append(IncludePath)
        import COOPIPAMRSetup
        COOPIPAMRSetup.DefineDatabases(DATABASES)
    except:
        pass
#************************BEGIN Optional CIS Import************************
def ImportCIS():
    try:
        IncludePath="/opt/cis"
        if(not IncludePath in sys.path):
            sys.path.append(IncludePath)
        import COOPIPCISSetup
        COOPIPCISSetup.DefineDatabases(DATABASES)
    except:
        pass
#************************BEGIN Optional GIS Import************************
def ImportGIS():
    try:
        IncludePath="/opt/gis"
        if(not IncludePath in sys.path):
            sys.path.append(IncludePath)
        import COOPIPGISSetup
        COOPIPGISSetup.DefineDatabases(DATABASES)
    except:
        pass
#************************BEGIN Optional GOS Import************************

#************************BEGIN Optional Web Import************************
def ImportWeb():
    try:
        IncludePath="/opt/web"
        if(not IncludePath in sys.path):
            sys.path.append(IncludePath)
        import COOPIPWebSetup
        COOPIPWebSetup.DefineDatabases(DATABASES)
    except:
        pass

def ImportExternalDatabases():
    ImportOMS()
    ImportAMR()
    ImportCIS()
    ImportGIS()
    ImportWeb()
ImportExternalDatabases()


StatusGroups=['COOPIP_Editor_Technology', 'COOPIP_Editor_Operations', 'COOPIP_Engineering']
DispatchEditorGroups=['COOPIP_Editor_Technology', 'COOPIP_Editor_Operations']
MeterPingMaximumOutCommands = 10  #Maximum number of commands in AMR
MeterPingMaximumPendingCommands = 20  #Maximum number of meters that can be marked ping in COOPIP that haven't been sent to AMR yet.  Meters with newly opened incidents override this.
MeterPingFastHours = [9,10,11,13,14,15]  #During these hours, send more pings out, as readings should be done and someone will be here to review the ping results on a display
MeterPingSlowHours = [0,1,2,3,4,5,6,7,8,12]  #During these hours, ping at a slower rate so as to not interfere with meter reads, Noontime hourly reads go out
AMRMeterCircuitUpdateMapNumbersToSkip=['19-1-4-18-11', '19-1-4-18-3','19-1-4-18-12', '19-2-4-18-16', '19-1-4-18-4', '19-1-4-18-14', '19-1-4-18-15', '19-1-4-18-16']


class COOPIPDatabaseRouter(object):
    def db_for_read(self, model, **hints):
        try:
            using=model.using
        except:
            using='default'
        return using
    def db_for_write(self, model, **hints):
        try:
            using=model.using
        except:
            using='default'
        return using
    def allow_relation(self, obj1, obj2, **hints):
        try:
            using=model.using
        except:
            using='default'
        return using
    def allow_syncdb(self, db, model):
        try:
            using=model.using
        except:
            using='default'
        if(using == 'default' and db == 'default'):
            return True
        else:
            return False





DATABASE_ROUTERS=['djangoproject.settings.COOPIPDatabaseRouter']



# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/New_York'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/opt/coopip/media/'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'SCRUBBED'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
 #   'django.template.loaders.filesystem.load_template_source',
    #'django.template.loaders.app_directories.load_template_source',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.middleware.doc.XViewMiddleware',
)

ROOT_URLCONF = 'djangoproject.urls'

TEMPLATE_DIRS = (
    '/opt/coopip/djangoproject/templates',

    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)



INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin',
    'django.contrib.gis',
    'djangoproject',
)


AUTHENTICATION_BACKENDS = {
    'django.contrib.auth.backends.ModelBackend',
}



SubstationMappingList=[]  #Format is GIS Circuit Number, AMR Substation ID, AMR Bus ID, AMR Fdr ID
SubstationMappingList.append([201, 5, 1, 1]) #St Matthews Calhoun Academy
SubstationMappingList.append([202, 5, 1, 2]) #St Matthews Tri County
SubstationMappingList.append([203, 5, 1, 3]) #St Matthews Moorer Rd
SubstationMappingList.append([204, 5, 1, 4]) #St Matthews Bellville Rd
SubstationMappingList.append([205, 5, 1, 5]) #St Matthews LoneStar

SubstationMappingList.append([301, 10, 2, 5]) #Eastover Hopkins Circuit
SubstationMappingList.append([302, 10, 2, 4]) #Eastover Gasden
SubstationMappingList.append([303, 10, 2, 3]) #Eastover Wateree 
SubstationMappingList.append([304, 10, 2, 2]) #Eastover Chain Gang
SubstationMappingList.append([305, 10, 2, 1]) #Eastover Steel Mill

SubstationMappingList.append([401, 2, 1, 1]) #Sandy Run Southeastern Frozen Foods
SubstationMappingList.append([402, 2, 1, 2]) #Sandy Run Sand Piper [HW?Y 176]
SubstationMappingList.append([403, 2, 1, 3]) #Sandy Run Hwy 21
SubstationMappingList.append([404, 2, 1, 4]) #Sandy Run Robbie Jackson
SubstationMappingList.append([405, 2, 1, 5]) #Sandy Run Wolfe Lake



SubstationMappingList.append([502, 7, 1, 1]) #Vance Eutawville
SubstationMappingList.append([503, 7, 1, 2]) #Vance MillCreek
SubstationMappingList.append([504, 7, 1, 3]) #Vance Resort
SubstationMappingList.append([505, 7, 1, 4]) #Vance Town Of Santee
SubstationMappingList.append([506, 7, 1, 5]) #Vance State Park

SubstationMappingList.append([601, 4, 1, 5]) #Burke Road Bethlehem School
SubstationMappingList.append([602, 4, 1, 4]) #Burke Road Kennerly Rd
SubstationMappingList.append([603, 4, 1, 3]) #Burke Road Orangeburg
SubstationMappingList.append([604, 4, 1, 2]) #Burke Road MurphMill
SubstationMappingList.append([606, 4, 1, 1]) #Burke Road Cartwright Road

SubstationMappingList.append([701, 11, 2, 1]) #Richland Coronet
SubstationMappingList.append([702, 11, 2, 2]) #Richland Screaming Eagle
SubstationMappingList.append([703, 11, 1, 4]) #Richland Congress
SubstationMappingList.append([704, 11, 1, 3]) #Richland Firetower

SubstationMappingList.append([801, 1, 1, 2]) #Silver Lake Rest Area
SubstationMappingList.append([802, 1, 1, 3]) #Silver Lake Old Silver Lake
SubstationMappingList.append([803, 1, 1, 1]) #Silver Lake Pine Plains
SubstationMappingList.append([804, 1, 1, 4]) #Silver Lake New Silver Lake


SubstationMappingList.append([902, 9, 1, 3]) #Hopkins Brook Store
SubstationMappingList.append([903, 9, 1, 2]) #Hopkins Lost John
SubstationMappingList.append([904, 9, 1, 4]) #Hopkins Dry Branch
SubstationMappingList.append([905, 9, 1, 1]) #Hopkins Meeting House

SubstationMappingList.append([1001, 6, 1, 3]) #Three Bridges Black Water
SubstationMappingList.append([1002, 6, 1, 1]) #Three Bridges Stump Hole
SubstationMappingList.append([1003, 6, 1, 2]) #Three Bridges Lone Star
SubstationMappingList.append([1004, 6, 1, 4]) #Three Bridges Santee Cemetery


SubstationMappingList.append([1101, 3, 1, 1]) #Hammonds Cross Water Tower
SubstationMappingList.append([1102, 3, 1, 2]) #Hammonds Cross Sunny Plains
SubstationMappingList.append([1103, 3, 1, 3]) #Hammonds Cross Jimmys Pit Stop
SubstationMappingList.append([1104, 3, 1, 4]) #Hammonds Cross Calhoun Road
SubstationMappingList.append([1105, 3, 1, 5]) #Hammonds Cross Congaree Church

SubstationMappingList.append([1201, 8, 1, 1]) #Wells Crane Pond
SubstationMappingList.append([1202, 8, 1, 2]) #Wells Chappel Davis
SubstationMappingList.append([1203, 8, 1, 3]) #Wells 210-6
SubstationMappingList.append([1204, 8, 1, 4]) #Wells Mayfield

SubstationMappingList.append([1301, 12, 1, 5]) #Oaks Elloree Feeder
SubstationMappingList.append([1302, 12, 1, 4]) #Oaks Midway
SubstationMappingList.append([1303, 12, 1, 3]) #Oaks Oaks Feeder
SubstationMappingList.append([1304, 12, 1, 2]) #Oaks Carriage Hill



















